#include "CAnnouncementsPanel.h"
#include "CGame.h"
#include "CGamePanel.h"
#include "CPlayerInfoPanel.h"

#include "CTurnSchedule.h"

unsigned int CTurnSchedule::Ticks = 0;
std::map<int, std::vector<ITurnTaker*> > CTurnSchedule::Schedule;

unsigned int CTurnSchedule::getSize()
{
    return Schedule[Ticks].size();
}

unsigned int CTurnSchedule::getTicks()
{
    return Ticks;
}

void CTurnSchedule::nextTurn()
{
	for (unsigned int i = 0; i < Schedule[Ticks].size(); ++i)
	{
		Schedule[Ticks][i]->takeTurn();
		CGamePanel::draw(gPlayer->getShape(), gPlayer->getPosition(), gPlayer->getSight(), gGame->getDungeon()->getFloor(gPlayer->getCurrentFloor()));
		CAnnouncementsPanel::draw();
		CPlayerInfoPanel::draw();
	}

	Schedule[Ticks].clear(); // no sense in keeping something we won't revisit
	Ticks++;
}

void CTurnSchedule::scheduleTurn(int interval, ITurnTaker* turnTaker)
{
	Schedule[Ticks+interval].push_back(turnTaker);
}
